#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r;
	cin>>n>>l>>r;
	if(r-l>=n)cout<<n-1;
	else{
		r=r%n;
		l=l%n;
		if(r<l)cout<<n-1;
		else{
			cout<<r;
		}
	}
	return 0;
} 
